package mysql

import "go_wep_demo/models"

func SaveArticle(data *models.ParamSaveArticle) (id int64, err error) {
	sqlStr := "insert into article(title,content,type_id) values(?,?,?)"
	ret, err := db.Exec(sqlStr, data.Title, data.Content, data.TypeId)
	if err != nil {
		return
	}
	id, _ = ret.LastInsertId()
	return
}

func GetArticleInfo(id int64) (articleInfo models.ArticleInfo, err error) {
	sqlStr := "select article_id,title,content,type_id,create_time from article where article_id = ?"
	err = db.Get(&articleInfo, sqlStr, id)
	if err != nil {
		return
	}
	return
}
